import request from '../utils/request.js'

//提供调用登录接口
export const userLoginService = (loginData)=>{
    const params = new URLSearchParams()
    for(let key in loginData){
        params.append(key,loginData[key])
    }
    return request.post('/user/login',params)
}

//获取用户详细信息
export const userInfoService = ()=>{
    return request.get('/user/info')
}

//提供调用注册接口的函数
export const userRegisterService = (registerData)=>{
    //借助于UrlSearchParams完成传递
    const params = new URLSearchParams()
    for(let key in registerData){
        params.append(key,registerData[key]);
    }
    return request.post('/user/register',params);
}

//提供修改用户信息函数
export const userInfoUpdateService = (userInfoData)=>{
    const params = new URLSearchParams()
    for(let key in userInfoData){
        params.append(key,userInfoData[key])
    }
    return request.patch('/user/updateinfo',params)
}

//提供修改用户密码函数
export const userPwdUpdateService = (userPwdData) => {

    return request.patch('/user/updatepwd',userPwdData)
    
}

//提供用户访问其他用户函数
export const otherInfoService = (userid) => {
    // const params = new URLSearchParams()
    // params.append("id",userid)
    return request.get('/user/getuser?id='+userid)
  
}

//修改头像
export const userAvatarUpdateService = (avatarUrl)=>{
    const params = new URLSearchParams();
    params.append('avatarurl',avatarUrl)
    return request.patch('/user/updateavatar',params)
}


